home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / demos / GL / libdemo / event.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  3.9 KB  |  121 lines

  1. /*
  2.  * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /*
  18.  *    event.h
  19.  * External interface and defines to input-queue event handling
  20.  * routines.
  21.  * Written by Wade Olsen for Silicon Graphics, Inc.
  22.  */
  23.  
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27.  
  28. /*
  29.  *    The event handler understands two kinds of things; events and
  30.  * updates.  Events are reactions to things occuring in the input
  31.  * queue.  Updates are functions that should be called whenever there
  32.  * is nothing waiting in the input queue, and may be active or
  33.  * inactive.  If there are no active updates and nothing in the input
  34.  * queue, then event() will block, using up no CPU time.
  35.  *
  36.  * add_event is used to look for events.  The first three arguments
  37.  * are used to identify which event to look for.  The first argument
  38.  * is the window (gid) the event must happen in; if this value is ANY
  39.  * then any window will do.  The second argument is the device to look
  40.  * for (e.g.  RIGHTMOUSE or REDRAW or KEYBD, etc).  Again, if it is
  41.  * ANY then any device will match.  The third argument is the value
  42.  * the device must generate (e.g.  DOWN or UP); ANY means all values
  43.  * match.  The last two arguments are what should be done when an
  44.  * event is generated.  The fourth argument is a function to be
  45.  * called, and the fifth is an argument that should be supplied to the
  46.  * function.  In addition, the value generated by the device will also
  47.  * be passed to the function when it is called.
  48.  *
  49.  * For example,
  50.  *    add_event(winget(), RIGHTMOUSE, DOWN, dopup, my_menus);
  51.  *    qdevice(RIGHTMOUSE);
  52.  * will make a pop-up menu appear when the right mousebutton goes
  53.  * down.  Note that you must do the qdevice() call yourself.
  54.  */
  55. void add_event(int, int, int, void (*fn)(), void *);
  56.  
  57. /*
  58.  * An update is like an event, only simpler.  The first argument is a
  59.  * pointer to an integer flag specifying whether or not this update
  60.  * function is active.  The second is a function to be called when it
  61.  * is active, and the last is an argument to be supplied to the
  62.  * function.
  63.  */
  64. void add_update(int *, void (*fn)(), void *);
  65.  
  66. /*
  67.  * Finally, when all updates and events have been added, repeatedly
  68.  * call event() to handle them -- something like
  69.  * 
  70.  *    while (quitflag == FALSE) event();
  71.  * 
  72.  * You should have previously added an event that sets quitflag to
  73.  * TRUE, of course.
  74.  */
  75. void event(void) ;
  76.  
  77. /*
  78.  *    event_noblock is similar to event but if there are no events or update
  79.  * to handle, it does not block.
  80.  */
  81. void event_noblock();
  82.  
  83.  
  84. /*
  85.  *    These are some useful defines for the possible values buttons
  86.  * can generate.
  87.  */
  88. #define ANY    -1
  89. #define UP    0
  90. #define DOWN    1
  91.  
  92. /*
  93.  *    And a few external variables you might find useful
  94.  */
  95. extern int context, state, device;
  96.  
  97.  
  98. /*
  99.  *    Allows you to delete event and update handlers.
  100.  */
  101. extern void delete_events(
  102.         int context, int device, int value, void *func);
  103.  
  104. extern void delete_updates(int * flag, void * func);
  105.  
  106. /*
  107.  *    Other useful event handlers
  108.  * 
  109.  * void setInt(void * i);            sets integer i to 1
  110.  * void resetInt(void * i);            sets integer i to 0
  111.  * void setIntToVal(void * i, int v);       sets integer i to the device
  112.  *                        value returned from qread
  113.  */
  114. extern void setInt();
  115. extern void resetInt();
  116. extern void setIntToVal();
  117.  
  118. #ifdef __cplusplus
  119. }
  120. #endif
  121.